// 路由配置模块

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';


// 引入路由需要的组件
import { NewsComponent } from './components/news/news.component';
import { HeaderComponent } from './components/header/header.component';
import { FormComponent } from './components/form/form.component';
import { SearchComponent } from './components/search/search.component';
import { TodolistComponent } from './components/todolist/todolist.component';
import { ViewchildComponent } from './components/viewchild/viewchild.component';
import { ComponentComponent } from './components/component/component.component';
import { LifefnComponent } from './components/lifefn/lifefn.component';
import { RxjsComponent } from './components/rxjs/rxjs.component'
import { NetworkComponent } from './components/network/network.component';
import { AxiosComponent } from './components/axios/axios.component';
import { RouterComponent } from './components/router/router.component';
import { RoutergetComponent } from './components/routerget/routerget.component';
import { RoutermainComponent } from './components/routermain/routermain.component';
import { RouterchildComponent } from './components/routerchild/routerchild.component';

// 配置路由
const routes: Routes = [
  {
    // 路径
    path:'home',
    // 对应的组件
    component:TodolistComponent
  },
  {
    path:'routermain',
    component:RoutermainComponent,
    children:[
      {
        path:'child',
        component:RouterchildComponent
      }
    ]
  },
  // 动态路由传值
  {
    path:'router/:routedata',
    component:RouterComponent
  },
  // get传参
  {
    path:'routerget',
    component:RoutergetComponent
  },

  // 重定向方法一
  // {
  //   path:'',
  //   // 重定向
  //   redirectTo:'home',
  //   pathMatch:'full'
  // }
  // 重定向方法二
  {
    path:'**',
    // 重定向
    redirectTo:'news',
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
